package com.baizhi.service.impl;

import com.baizhi.dao.CmfzAlbumDao;
import com.baizhi.entity.CmfzAlbum;
import com.baizhi.service.CmfzAlbumService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * @Author: renpu
 * @Date: 2019/2/27 11:46
 * @Description:
 */
@Service
@Transactional
public class CmfzAlbumServiceImpl implements CmfzAlbumService {
    @Autowired
    private CmfzAlbumDao albumDao;
    @Override
    public Map selectByPage(int rows, int page) {
        Map map=new HashMap();
        int start=(page-1)*rows+1;
        int pagesize=rows;
        List<CmfzAlbum> list=albumDao.selectByPage(start,pagesize);
        int count=albumDao.selectCount();
        map.put("rows",list);
        map.put("total",count);
        return map;
    }

    @Override
    public void insert(CmfzAlbum album) {
        albumDao.insert(album);
    }

    @Override
    public void update(CmfzAlbum album) {
        albumDao.update(album);

    }

    @Override
    public void deleteMore(int[] ids) {
        for (int id:ids) {
            albumDao.delete(id);
        }
    }

    @Override
    public List<CmfzAlbum> selectBestAlubm() {
        return albumDao.selectBestAlubm();
    }

    @Override
    public CmfzAlbum selectOneAlbum(int id) {
        return albumDao.selectOneAlbum(id);
    }

    @Override
    public CmfzAlbum selectAudioId(int id) {
        return albumDao.selectAudioId(id);
    }

    @Override
    public List<CmfzAlbum> selectAlbumAll() {
        return albumDao.selectAlbumAll();
    }
}
